<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="${basePath}/assets/layui/css/layui.css"
	media="all">
<link href="${basePath}/static/css/Pigeonhole/Pigeonhole_list.css"
	rel="stylesheet" type="text/css">
<link rel="stylesheet"
	href="${basePath}/static/css/medicalRecord_Search/medicalSearch.css" />
<script type="text/javascript"
	src="${basePath}/static/publics/assets/jqPaginator/jqPaginator.js"></script>
<div class="list_NR">
	<div class="loc">
		<h3>统计报告</h3>
		<ul class="loc_loc">参数查询
		</ul>
	</div>

	<table id="newsList" lay-filter="newsList"></table>
	
	<!--操作-->
		<script type="text/html" id="newsListBar">
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="view">设置</a>
			<a class="layui-btn layui-btn-xs" lay-event="edit">删除</a>
		</script>


</div>
<script type="text/javascript" src="${basePath}/assets/js/dataFormat.js"></script>
<script type="text/javascript" src="${basePath}/assets/layui/layui.js"></script>

	<script type="text/javascript">
	layui.use(['form','layer','laydate','table','laytpl'],function(){
	    var form = layui.form,
	        layer = parent.layer === undefined ? layui.layer : top.layer,
	        $ = layui.jquery,
	        laydate = layui.laydate,
	        laytpl = layui.laytpl,
	        table = layui.table;

		laydate.render({
			elem: '#start',
			type: 'date',
			trigger : "click",
			done : function(value, date, endDate){
				submitTime = value;
			}
		});

		laydate.render({
			elem: '#end',
			type: 'date',
			trigger : "click",
			done : function(value, date, endDate){
				submitTime = value;
			}
		});

	    //新闻列表
	    var tableIns = table.render({
	        elem: '#newsList',
	        url : '${pageContext.request.contextPath }/report/getStatisticalReportParamPageInfo',
	        cellMinWidth : 95,
	        page : true,
	       // height : "full-185",
	        limit : 10,
	        limits : [10,15,20,25],
	        id : "newsListTable",
	        cols : [[
				
				{field: 'statics1StartTime', title: '参数1开始时间', align:'center', templet:function(d){
					if(d.statics1StartTime == null){
						return "";
					}
					return new Date(d.statics1StartTime).format("yyyy-MM-dd");
				}
				},
				{field: 'statics1EndTime', title: '参数1结束时间', align:'center', templet:function(d){
					if(d.statics1EndTime == null){
						return "";
					}
					return new Date(d.statics1EndTime).format("yyyy-MM-dd");
				}
				},
	            {field: 'statics1Name', title: '参数1别名', width:100, align:"center"},
	            {field: 'recordTime', title: '创建时间', align:'center', templet:function(d){
					if(d.recordTime == null){
						return "";
					}
					return new Date(d.recordTime).format("yyyy-MM-dd");
				}
				},
	          
	            {title: '操作', width:120, templet:'#newsListBar', fixed:"right", align:"center"}
	        ]]
	    });
	
	
	    //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
	    $(".search_btn").on("click",function(){

	    	var keyword = $(".searchVal").val();
	    	var start = $("#start").val();
			var end = $("#end").val();

	        if(keyword || start || end){
	            table.reload("newsListTable",{
	            	url:'${pageContext.request.contextPath }//report/getStatisticalReportParamPageInfo',
	                page: {
	                    curr: 1 //重新从第 1 页开始
	                },
	                where: {

					/* 	name: keyword,  //搜索的关键字
						start:start,
						end: end */
	                }
	            });
	        }else{
	            layer.msg("请输入搜索的内容");
	        }
	    });

		$(".add_btn").click(function(){
			addBasic();
		});
	
	    //添加文章
	    function addBasic(){
	    	var content = "${pageContext.request.contextPath }/ops/handOverIntraoperativeAdd";
	        var index = layui.layer.open({
	            title : "添加信息",
	            type : 2,
	            content : content,
	            success : function(layero, index){
	                var body = layui.layer.getChildFrame('body', index);
	                setTimeout(function(){
	                    layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
	                        tips: 3
	                    });
	                },500);
	            }
	        });
	        layui.layer.full(index);
	        //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
	        $(window).on("resize",function(){
	            layui.layer.full(index);
	        });
	    }

		//删除
		function deleteBasic(edit){
			var id = edit.id;
			$.ajax({
				type:"post",
				data:{id:id},
				url:"${basePath}/report/deleteParamSettingById",
				success:function(data){
					if(data.success){
						layer.alert("参数删除成功!",{icon:1});
						window.location.href="${basePath}/report/searchParameterSettingPage";
					}
				}
			});
			
		}

		function viewBasic(edit){
			
			var id = edit.id;
			$.ajax({
				type:"post",
				data:{id:id},
				url:"${basePath}/report/updateParamSetting",
				success:function(data){
					if(data.success){
						layer.msg("参数已重新设置，请继续操作");
					}
				}
			})
			/* var content = "${pageContext.request.contextPath }/ops/applyOperationUpdate?applyOperationId=" + edit.id + "&serialNumberId=" + edit.serialNumber + "&view=1";
			var index = layui.layer.open({
				title : "添加信息",
				type : 2,
				content : content,
				success : function(layero, index){
					var body = layui.layer.getChildFrame('body', index);
					setTimeout(function(){
						layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
							tips: 3
						});
					},500);
				}
			});
			layui.layer.full(index);
			//改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
			$(window).on("resize",function(){
				layui.layer.full(index);
			}); */
		}

	    //列表操作
	    table.on('tool(newsList)', function(obj){
	        var layEvent = obj.event,
	            data = obj.data;
	
	        if(layEvent === 'edit'){ //编
				deleteBasic(data);
	        }else if(layEvent === 'view'){
				viewBasic(data);
			}
	    });
	
	});
	</script>